﻿ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ScriptEditor.Commands
{
    class Command_SoundFX : Command
    {
        public string gameSFXName
        {
            get
            {
                return Value1;
            }
            set
            {
                Value1 = value;
            }
        }
        public float duration
        {
            get
            {
                return float.TryParse(Value2, out float result) ? result : 0.5f;
            }
            set
            {
                Value2 = value.ToString();
            }
        }
        public bool loop
        {
            get
            {
                return bool.TryParse(Value3, out bool result) ? result : false;
            }
            set
            {
                Value3 = value.ToString();
            }
        }
        public bool play
        {
            get
            {
                if (Value4 == "PLAY"||Value4=="")
                {
                    return true;
                }
                return false;
            }
            set
            {
                Value4 = (value) ? "PLAY" : "STOP";
            }
        }
        public float volumeScale
        {
            get
            {
                return float.TryParse(Value5, out float result) ? result : 0.5f;
            }
            set
            {
                Value5 = value.ToString();
            }
        }
        public string cueSheet
        {
            get
            {
                return Value6;
            }
            set
            {
                Value6 = value;
            }
        }
        public Command_SoundFX()
        {
            CommandType = COMMANDTYPE.SoundFX;
            gameSFXName = "请输入音效名";
            duration = 0.5f;
            loop = false;
            play = true;
            volumeScale = 0.5f;
            cueSheet = "VnCommon";
            Wait = false;
        }
        public Command_SoundFX(string GameSFXName, float Duration, bool Loop, bool Play, float VolumeScale, string CueSheet="Audio")
        {
            CommandType = COMMANDTYPE.SoundFX;
            gameSFXName = GameSFXName;
            duration = Duration;
            loop = Loop;
            play = Play;
            volumeScale = VolumeScale;
            cueSheet = CueSheet;
            Wait = false;
        }
        public override string ToString()
        {
            return CommandType.ToString() + ":\n" + "播放效果音:" + gameSFXName + " " + cueSheet;
        }
    }
}
